﻿namespace NEvoWeb.Modules.NB_Store
{
    using DotNetNuke.Common;
    using DotNetNuke.Common.Utilities;
    using DotNetNuke.Entities.Portals;
    using DotNetNuke.Entities.Users;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Xml;

    public class ProductTemplate : ITemplate
    {
        protected string[] _aryTempl;
        protected bool _blnHasModuleEditPermissions;
        protected string _BuyText;
        protected int _CatID;
        protected string _CssBuyButton;
        protected string _EditCtrlKey;
        protected string _GalleryThumbSize;
        protected bool _LockStockOnCart;
        protected string _ModuleID;
        protected ArrayList _NestedLevel;
        protected int _PageIndex;
        protected int _ProductTabID;
        protected int _QtyLimit;
        protected List<int> _RelatedList;
        protected string _SoldOutImg;
        protected string _StoreInstallPath;
        protected int _TabID;
        protected string _ThumbSize;
        protected int _UserID;
        protected UserInfo _UserInfo;
        protected string _ZeroPriceMsg;

        public ProductTemplate(int TabID, int ModuleID, string StoreInstallPath, string ThumbSize, string TemplateText, bool blnHasModuleEditPermissions, string BuyText, string CssBuyButton, int PageIndex, int CatID, string GalleryThumbSize, string EditCtrlKey, int ProductTabID, int UserID, UserInfo UserInfo, string ZeroPriceMsg = "", string SoldOutImg = "", bool LockStockOnCart = false, int QtyLimit = 0xf423f, List<int> RelatedList = null)
        {
            this._RelatedList = RelatedList;
            this._aryTempl = this.ParseTemplateText(TemplateText);
            this._TabID = TabID;
            this._PageIndex = PageIndex;
            this._StoreInstallPath = StoreInstallPath;
            this._ThumbSize = ThumbSize;
            this._blnHasModuleEditPermissions = blnHasModuleEditPermissions;
            this._ModuleID = Conversions.ToString(ModuleID);
            this._CatID = CatID;
            this._GalleryThumbSize = GalleryThumbSize;
            if (this._GalleryThumbSize == "")
            {
                this._GalleryThumbSize = "100";
            }
            if (this._ThumbSize == "")
            {
                this._ThumbSize = "150";
            }
            this._BuyText = BuyText;
            this._CssBuyButton = CssBuyButton;
            if (this._CssBuyButton == "")
            {
                this._CssBuyButton = "CommandButton";
            }
            this._EditCtrlKey = EditCtrlKey;
            this._ProductTabID = ProductTabID;
            this._UserInfo = UserInfo;
            if (this._UserInfo == null)
            {
                this._UserID = -1;
            }
            else
            {
                this._UserID = this._UserInfo.UserID;
            }
            this._ZeroPriceMsg = ZeroPriceMsg;
            this._SoldOutImg = SoldOutImg;
            this._LockStockOnCart = LockStockOnCart;
            this._QtyLimit = QtyLimit;
            this._NestedLevel = new ArrayList();
            this._NestedLevel.Add(true);
        }

        private void AddToBasket_DataBinding(object sender, EventArgs e)
        {
            LinkButton button = (LinkButton) sender;
            DataListItem namingContainer = (DataListItem) button.NamingContainer;
            button.CommandArgument = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
            button.CommandName = "AddToBasket";
            button.CssClass = this._CssBuyButton;
            button.Text = this._BuyText;
            if (Operators.ConditionalCompareObjectEqual(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "QtyRemaining"), 0, false))
            {
                button.Visible = false;
            }
            else
            {
                ArrayList list;
                ProductController controller = new ProductController();
                NB_Store_ModelInfo info = new NB_Store_ModelInfo();
                int productID = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
                string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang"));
                PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
                if (this._LockStockOnCart)
                {
                    list = SharedFunctions.GetAvailableModelList(currentPortalSettings.PortalId, productID, lang, SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture()));
                }
                else
                {
                    list = controller.GetModelList(-1, productID, lang, SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture()));
                }
                HiddenField field = (HiddenField) namingContainer.FindControl("hfModel");
                if ((field != null) && (field.Value != ""))
                {
                    SharedFunctions.assignByReflection(button, field.Value);
                }
                if (list.Count >= 1)
                {
                    info = (NB_Store_ModelInfo) list[0];
                    if (field != null)
                    {
                        field.Value = Conversions.ToString(info.ModelID);
                    }
                }
                else
                {
                    button.Visible = false;
                }
            }
            if (button.Visible)
            {
                button.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void AddToRelated_DataBinding(object sender, EventArgs e)
        {
            LinkButton button = (LinkButton) sender;
            DataListItem namingContainer = (DataListItem) button.NamingContainer;
            string str = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
            button.Attributes.Add("onclick", string.Format("javascript:return addToRelated(this, '{0}', {1}, {2});", VirtualPathUtility.ToAbsolute("~/DesktopModules/NB_Store/XMLProvider.ashx"), HttpContext.Current.Request.QueryString["ProdId"], str));
            button.CommandArgument = str;
            button.CommandName = "AddRelated";
            button.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            if (this._RelatedList.IndexOf(int.Parse(str)) != -1)
            {
                button.Visible = false;
            }
        }

        private void AddToWishList_DataBinding(object sender, EventArgs e)
        {
            LinkButton button = (LinkButton) sender;
            DataListItem namingContainer = (DataListItem) button.NamingContainer;
            button.CommandArgument = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
            button.CommandName = "AddToWishList";
            button.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private object assignProperties(string TagString, object obj, string IdPrefix = "")
        {
            string[] strArray = TagString.Split(new char[] { ':' });
            NewLateBinding.LateSet(obj, null, "ID", new object[] { IdPrefix + strArray[1].ToLower() }, null, null);
            if (strArray.GetUpperBound(0) >= 2)
            {
                obj = RuntimeHelpers.GetObjectValue(SharedFunctions.assignByReflection(RuntimeHelpers.GetObjectValue(obj), strArray[2]));
            }
            return obj;
        }

        private void BestPrice_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getBestPriceOutput(namingContainer, false);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void BestPriceCurrency_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getBestPriceOutput(namingContainer, true);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void CatImageURL_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            NB_Store_CategoriesInfo category = new CategoryController().GetCategory(this._CatID, SharedFunctions.GetCurrentCulture());
            if (category != null)
            {
                literal.Text = category.ImageURL;
            }
            else
            {
                literal.Text = "";
            }
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void CatName_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            NB_Store_CategoriesInfo category = new CategoryController().GetCategory(this._CatID, SharedFunctions.GetCurrentCulture());
            if (category != null)
            {
                literal.Text = category.CategoryName;
            }
            else
            {
                literal.Text = "";
            }
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void ClassDataBind_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), literal.Text).ToString();
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void CreateGatewayRadioButList(RadioButtonList rbl, bool AlwaysDisplay)
        {
            IEnumerator enumerator=null;
            DataListItem namingContainer = (DataListItem) rbl.NamingContainer;
            ArrayList availableGateways = SharedFunctions.GetAvailableGateways(PortalController.GetCurrentPortalSettings().PortalId);
            try
            {
                enumerator = availableGateways.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_GatewayInfo current = (NB_Store_GatewayInfo) enumerator.Current;
                    ListItem item = new ListItem {
                        Value = current.@ref,
                        Text = current.gatewaymsg
                    };
                    rbl.Items.Add(item);
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
        }

        private void CreateModelDropDownList(DropDownList ddl, bool AlwaysDisplay)
        {
            DataListItem namingContainer = (DataListItem) ddl.NamingContainer;
            ProductController controller = new ProductController();
            PromoController controller2 = new PromoController();
            NB_Store_ModelInfo objMInfo = new NB_Store_ModelInfo();
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            ArrayList list = controller.GetModelList(-1, Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")), SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture()));
            if ((list.Count <= 1) & !AlwaysDisplay)
            {
                ddl.Visible = false;
            }
            else
            {
                IEnumerator enumerator=null;
                IEnumerator enumerator2=null;
                bool flag = false;
                decimal unitCost = ((NB_Store_ModelInfo) list[0]).UnitCost;
                try
                {
                    enumerator = list.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        objMInfo = (NB_Store_ModelInfo) enumerator.Current;
                        if (decimal.Compare(objMInfo.UnitCost, unitCost) != 0)
                        {
                            flag = true;
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                int productID = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
                string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang"));
                list = SharedFunctions.GetAvailableModelList(currentPortalSettings.PortalId, productID, lang, SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture()));
                if (list.Count <= 0)
                {
                    ddl.Visible = false;
                }
                try
                {
                    enumerator2 = list.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                        objMInfo = (NB_Store_ModelInfo) enumerator2.Current;
                        ListItem item = new ListItem();
                        if (flag)
                        {
                            if (SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, lang))
                            {
                                if ((decimal.Compare(objMInfo.UnitCost, decimal.Zero) > 0) & (decimal.Compare(objMInfo.DealerCost, objMInfo.UnitCost) != 0))
                                {
                                    item.Text = objMInfo.ModelName + " (" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.UnitCost)) + ") " + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.DealerCost));
                                }
                                else
                                {
                                    item.Text = objMInfo.ModelName + " " + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.DealerCost));
                                }
                            }
                            else
                            {
                                double num = Convert.ToDouble(controller2.GetSalePrice(objMInfo, this._UserInfo));
                                if (((num > -1.0) & (decimal.Compare(objMInfo.UnitCost, decimal.Zero) > 0)) & !(Convert.ToDouble(objMInfo.UnitCost) == num))
                                {
                                    item.Text = objMInfo.ModelName + " (" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.UnitCost)) + ") " + SharedFunctions.FormatToStoreCurrency(num);
                                }
                                else
                                {
                                    item.Text = objMInfo.ModelName + " " + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.UnitCost));
                                }
                            }
                        }
                        else
                        {
                            item.Text = objMInfo.ModelName;
                        }
                        item.Value = Conversions.ToString(objMInfo.ModelID);
                        ddl.Items.Add(item);
                        if (objMInfo.QtyRemaining == 0)
                        {
                            string str2 = SharedFunctions.GetStoreSettingText(currentPortalSettings.PortalId, "outofstockmodelmsg.text", lang);
                            if (str2 != "")
                            {
                                ListItem item3 = ddl.Items[ddl.Items.Count - 1];
                                item3.Text = item3.Text + str2;
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator2 is IDisposable)
                    {
                        (enumerator2 as IDisposable).Dispose();
                    }
                }
                if (list.Count > 0)
                {
                    ddl.SelectedIndex = 0;
                }
            }
            if (ddl.Visible)
            {
                ddl.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void CreateModelRadioButList(RadioButtonList rbl, bool AlwaysDisplay)
        {
            DataListItem namingContainer = (DataListItem) rbl.NamingContainer;
            ProductController controller = new ProductController();
            PromoController controller2 = new PromoController();
            NB_Store_ModelInfo objMInfo = new NB_Store_ModelInfo();
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            ArrayList list = controller.GetModelList(-1, Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")), SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture()));
            if ((list.Count <= 1) & !AlwaysDisplay)
            {
                rbl.Visible = false;
            }
            else
            {
                IEnumerator enumerator=null;
                IEnumerator enumerator2=null;
                bool flag = false;
                decimal unitCost = ((NB_Store_ModelInfo) list[0]).UnitCost;
                try
                {
                    enumerator = list.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        objMInfo = (NB_Store_ModelInfo) enumerator.Current;
                        if (decimal.Compare(objMInfo.UnitCost, unitCost) != 0)
                        {
                            flag = true;
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                int productID = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
                string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang"));
                list = SharedFunctions.GetAvailableModelList(currentPortalSettings.PortalId, productID, lang, SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture()));
                if (list.Count <= 0)
                {
                    rbl.Visible = false;
                }
                try
                {
                    enumerator2 = list.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                        objMInfo = (NB_Store_ModelInfo) enumerator2.Current;
                        ListItem item = new ListItem();
                        if (flag)
                        {
                            if (SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, lang))
                            {
                                if ((decimal.Compare(objMInfo.UnitCost, decimal.Zero) > 0) & (decimal.Compare(objMInfo.DealerCost, objMInfo.UnitCost) != 0))
                                {
                                    item.Text = objMInfo.ModelName + " (" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.UnitCost)) + ") " + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.DealerCost));
                                }
                                else
                                {
                                    item.Text = objMInfo.ModelName + " " + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.DealerCost));
                                }
                            }
                            else
                            {
                                double num = Convert.ToDouble(controller2.GetSalePrice(objMInfo, this._UserInfo));
                                if (((num > -1.0) & (decimal.Compare(objMInfo.UnitCost, decimal.Zero) > 0)) & !(Convert.ToDouble(objMInfo.UnitCost) == num))
                                {
                                    item.Text = objMInfo.ModelName + " (" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.UnitCost)) + ") " + SharedFunctions.FormatToStoreCurrency(num);
                                }
                                else
                                {
                                    item.Text = objMInfo.ModelName + " " + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(objMInfo.UnitCost));
                                }
                            }
                        }
                        else
                        {
                            item.Text = objMInfo.ModelName;
                        }
                        item.Value = Conversions.ToString(objMInfo.ModelID);
                        rbl.Items.Add(item);
                        if (objMInfo.QtyRemaining == 0)
                        {
                            rbl.Items[rbl.Items.Count - 1].Enabled = false;
                            string str2 = SharedFunctions.GetStoreSettingText(currentPortalSettings.PortalId, "outofstockmodelmsg.text", lang);
                            if (str2 != "")
                            {
                                ListItem item3 = rbl.Items[rbl.Items.Count - 1];
                                item3.Text = item3.Text + str2;
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator2 is IDisposable)
                    {
                        (enumerator2 as IDisposable).Dispose();
                    }
                }
                if (list.Count > 0)
                {
                    rbl.SelectedIndex = 0;
                }
            }
            if (rbl.Visible)
            {
                rbl.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void CurrencyISOcode_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            literal.Text = SharedFunctions.getCurrencyISOCode();
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void CurrencySymbol_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            literal.Text = SharedFunctions.getCurrencySymbol();
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void DealerPrice_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getFromDealerPriceOutput(namingContainer, false);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void DealerPriceCurrency_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getFromDealerPriceOutput(namingContainer, true);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Description_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = HttpUtility.HtmlDecode(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Description")));
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Doc_DataBinding(object sender, EventArgs e)
        {
            ProductController controller = new ProductController();
            string find = "doc";
            ImageButton button = (ImageButton) sender;
            if (button.ID.ToLower().StartsWith("docpurchased"))
            {
                find = "docpurchased";
            }
            else
            {
                find = "doc";
            }
            DataListItem namingContainer = (DataListItem) button.NamingContainer;
            int num = -1;
            if (Versioned.IsNumeric(Strings.Replace(button.ID, find, "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(button.ID, find, "", 1, -1, CompareMethod.Binary)) - 1;
            }
            button.Visible = false;
            if (num >= 0)
            {
                ArrayList productDocList = controller.GetProductDocList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (productDocList.Count >= (num + 1))
                {
                    NB_Store_ProductDocInfo info = (NB_Store_ProductDocInfo) productDocList[num];
                    button.CommandArgument = Conversions.ToString(info.DocID);
                    if (find == "docpurchased")
                    {
                        button.CommandName = "DocPurchased";
                    }
                    else
                    {
                        button.CommandName = "DocDownload";
                    }
                    if (button.ImageUrl == "")
                    {
                        string str2 = info.FileExt.ToLower();
                        if (str2 == ".pdf")
                        {
                            button.ImageUrl = this._StoreInstallPath + "img/pdf.png";
                        }
                        else if (str2 == ".zip")
                        {
                            button.ImageUrl = this._StoreInstallPath + "img/zip.png";
                        }
                        else
                        {
                            button.ImageUrl = this._StoreInstallPath + "img/disk.png";
                        }
                    }
                    if (button.ToolTip == "")
                    {
                        button.ToolTip = info.DocDesc;
                    }
                    if (find == "doc")
                    {
                        button.Visible = true;
                    }
                    else if (SharedFunctions.DocHasBeenPurchased(this._UserID, info.ProductID))
                    {
                        button.Visible = true;
                    }
                    else
                    {
                        button.Visible = false;
                    }
                }
            }
            if (button.Visible)
            {
                button.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void DocDesc_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            ProductController controller = new ProductController();
            string find = "docdesc";
            int num = -1;
            if (Versioned.IsNumeric(Strings.Replace(literal.ID, find, "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(literal.ID, find, "", 1, -1, CompareMethod.Binary)) - 1;
            }
            if (num >= 0)
            {
                ArrayList productDocList = controller.GetProductDocList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (productDocList.Count >= (num + 1))
                {
                    NB_Store_ProductDocInfo info = (NB_Store_ProductDocInfo) productDocList[num];
                    literal.Text = info.DocDesc;
                }
            }
            if (literal.Visible)
            {
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void DocLink_DataBinding(object sender, EventArgs e)
        {
            ProductController controller = new ProductController();
            string find = "doclink";
            LinkButton button = (LinkButton) sender;
            if (button.ID.ToLower().StartsWith("doclink"))
            {
                find = "doclink";
            }
            else
            {
                find = "docpurchasedlink";
            }
            DataListItem namingContainer = (DataListItem) button.NamingContainer;
            int num = -1;
            if (Versioned.IsNumeric(Strings.Replace(button.ID, find, "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(button.ID, find, "", 1, -1, CompareMethod.Binary)) - 1;
            }
            button.Visible = false;
            if (num >= 0)
            {
                ArrayList productDocList = controller.GetProductDocList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (productDocList.Count >= (num + 1))
                {
                    NB_Store_ProductDocInfo info = (NB_Store_ProductDocInfo) productDocList[num];
                    button.CommandArgument = Conversions.ToString(info.DocID);
                    if (find == "docpurchasedlink")
                    {
                        button.CommandName = "DocPurchased";
                    }
                    else
                    {
                        button.CommandName = "DocDownload";
                    }
                    if (button.Text == "")
                    {
                        button.Text = info.DocDesc;
                    }
                    if (button.ToolTip == "")
                    {
                        button.ToolTip = info.FileName;
                    }
                    if (find == "doclink")
                    {
                        button.Visible = true;
                    }
                    else if (SharedFunctions.DocHasBeenPurchased(this._UserID, info.ProductID))
                    {
                        button.Visible = true;
                    }
                    else
                    {
                        button.Visible = false;
                    }
                }
            }
            if (button.Visible)
            {
                button.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void DocName_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            ProductController controller = new ProductController();
            string find = "docname";
            int num = -1;
            if (Versioned.IsNumeric(Strings.Replace(literal.ID, find, "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(literal.ID, find, "", 1, -1, CompareMethod.Binary)) - 1;
            }
            if (num >= 0)
            {
                ArrayList productDocList = controller.GetProductDocList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (productDocList.Count >= (num + 1))
                {
                    NB_Store_ProductDocInfo info = (NB_Store_ProductDocInfo) productDocList[num];
                    literal.Text = info.FileName.Replace("%20", " ");
                }
            }
            if (literal.Visible)
            {
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void EditLink_DataBinding(object sender, EventArgs e)
        {
            HyperLink link = (HyperLink) sender;
            DataListItem namingContainer = (DataListItem) link.NamingContainer;
            if (this._blnHasModuleEditPermissions)
            {
                link.ImageUrl = "~/images/edit.gif";
                link.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(this._TabID, this._EditCtrlKey, new string[] { "mid=" + this._ModuleID, Conversions.ToString(Operators.ConcatenateObject("ProdID=", DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"))), "RtnTab=" + this._TabID.ToString(), "PageIndex=" + this._PageIndex.ToString(), "CatID=" + this._CatID.ToString(), "SkinSrc=" + DotNetNuke.Common.Globals.QueryStringEncode(DotNetNuke.Common.Globals.ResolveUrl("~/DesktopModules/NB_Store/Skins/Dark/Edit")) });
            }
            else
            {
                link.Visible = false;
            }
            if (link.Visible)
            {
                link.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void EXTRA_DataBinding(object sender, EventArgs e)
        {
            if (TagExtraInterface.Instance() != null)
            {
                Literal literal = (Literal) sender;
                DataListItem namingContainer = (DataListItem) literal.NamingContainer;
                PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
                literal.Text = TagExtraInterface.Instance().getExtraHtml(currentPortalSettings.PortalId, namingContainer, literal.Text);
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void FileUpload_DataBinding(object sender, EventArgs e)
        {
            FileUpload upload = (FileUpload) sender;
            if (upload.Visible)
            {
                upload.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void FromPrice_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getFromPrice(namingContainer, false);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void FromPriceCurrency_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getFromPrice(namingContainer, true);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void FromPriceTax_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getFromPriceWithAppliedTax(namingContainer, false);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void FromPriceTaxCurrency_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getFromPriceWithAppliedTax(namingContainer, true);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Gallery_DataBinding(object sender, EventArgs e)
        {
            string str4;
            SettingsController controller2 = new SettingsController();
            ProductController controller = new ProductController();
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            int num = -1;
            string thumbH = "0";
            if (!Versioned.IsNumeric(this._GalleryThumbSize))
            {
                string[] strArray = this._GalleryThumbSize.Split(new char[] { 'x' });
                str4 = strArray[0];
                if (strArray.GetUpperBound(0) == 1)
                {
                    thumbH = strArray[1];
                }
            }
            else
            {
                str4 = this._GalleryThumbSize;
            }
            string expression = "<A HREF=\"[Product:ImageURL]\" rel=\"GRP1\" class=\"nyroModal\" title=\"[Product:ImageDesc]\"><img border=\"0\" src=\"[Product:ImageThumb]\" alt=\"[Product:ImageDesc]\"/></A>";
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            NB_Store_SettingsInfo info2 = controller2.GetSetting(currentPortalSettings.PortalId, "lightboxgallerytemplate.name", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
            string settingName = "nyromodalgallery.template";
            if (info2 != null)
            {
                settingName = info2.SettingValue;
            }
            NB_Store_SettingsTextInfo info3 = controller2.GetSettingsText(currentPortalSettings.PortalId, settingName, Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
            if (info3 != null)
            {
                expression = HttpUtility.HtmlDecode(info3.SettingText);
            }
            if (Versioned.IsNumeric(Strings.Replace(literal.ID, "gallery", "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(literal.ID, "gallery", "", 1, -1, CompareMethod.Binary)) - 1;
            }
            literal.ID = "";
            if (num >= 0)
            {
                ArrayList productImageList = controller.GetProductImageList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (productImageList.Count >= (num + 1))
                {
                    NB_Store_ProductImageInfo info = (NB_Store_ProductImageInfo) productImageList[num];
                    string imageURL = info.ImageURL;
                    if (imageURL == "")
                    {
                        imageURL = "noimage.png";
                        expression = "<img border=\"0\" src=\"[Product:ImageThumb]\" alt=\"[Product:ImageDesc]\"/>";
                        info3 = controller2.GetSettingsText(currentPortalSettings.PortalId, "noimagegallery.template", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                        if (info3 != null)
                        {
                            expression = HttpUtility.HtmlDecode(info3.SettingText);
                        }
                    }
                    expression = Strings.Replace(expression, "[Product:ImageURL]", imageURL, 1, -1, CompareMethod.Binary);
                    if (info.ImageDesc == "")
                    {
                        if (Operators.ConditionalCompareObjectEqual(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "SEOName"), "", false))
                        {
                            expression = Strings.Replace(expression, "[Product:ImageDesc]", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductName")), 1, -1, CompareMethod.Binary);
                        }
                        else
                        {
                            expression = Strings.Replace(expression, "[Product:ImageDesc]", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "SEOName")), 1, -1, CompareMethod.Binary);
                        }
                    }
                    else
                    {
                        expression = Strings.Replace(expression, "[Product:ImageDesc]", info.ImageDesc, 1, -1, CompareMethod.Binary);
                    }
                    if (SharedFunctions.GetStoreSettingBoolean(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "PortalID")), "diskthumbnails.flag"))
                    {
                        string replacement = new ThumbFunctions().GetThumbURLName(imageURL, str4, thumbH);
                        if (replacement == "")
                        {
                            expression = Strings.Replace(expression, "[Product:ImageThumb]", this._StoreInstallPath + "makethumbnail.ashx?Image=" + info.ImageID.ToString() + "&amp;w=" + str4 + "&amp;tabid=" + Conversions.ToString(this._TabID) + "&amp;h=" + thumbH, 1, -1, CompareMethod.Binary);
                        }
                        else
                        {
                            expression = Strings.Replace(expression, "[Product:ImageThumb]", replacement, 1, -1, CompareMethod.Binary);
                        }
                    }
                    else
                    {
                        expression = Strings.Replace(expression, "[Product:ImageThumb]", this._StoreInstallPath + "makethumbnail.ashx?Image=" + info.ImageID.ToString() + "&amp;w=" + str4 + "&amp;tabid=" + Conversions.ToString(this._TabID) + "&amp;h=" + thumbH, 1, -1, CompareMethod.Binary);
                    }
                    literal.Text = expression;
                }
                else
                {
                    literal.Text = "";
                }
            }
            else
            {
                literal.Text = "";
            }
            if (literal.Text == "")
            {
                literal.Visible = false;
            }
            if (literal.Visible)
            {
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void GalleryId_DataBinding(object sender, EventArgs e)
        {
            ProductController controller = new ProductController();
            int num = -1;
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            if (Versioned.IsNumeric(Strings.Replace(literal.ID, "galleryid", "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(literal.ID, "galleryid", "", 1, -1, CompareMethod.Binary)) - 1;
            }
            literal.ID = "";
            if (num >= 0)
            {
                ArrayList productImageList = controller.GetProductImageList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (productImageList.Count >= (num + 1))
                {
                    NB_Store_ProductImageInfo info = (NB_Store_ProductImageInfo) productImageList[num];
                    literal.Text = info.ImageID.ToString();
                }
                else
                {
                    literal.Text = "";
                }
            }
            else
            {
                literal.Text = "";
            }
            if (literal.Text == "")
            {
                literal.Visible = false;
            }
            if (literal.Visible)
            {
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void GalleryThumbUrl_DataBinding(object sender, EventArgs e)
        {
            string str2;
            string thumbH = "0";
            if (!Versioned.IsNumeric(this._GalleryThumbSize))
            {
                string[] strArray = this._GalleryThumbSize.Split(new char[] { 'x' });
                str2 = strArray[0];
                if (strArray.GetUpperBound(0) == 1)
                {
                    thumbH = strArray[1];
                }
            }
            else
            {
                str2 = this._GalleryThumbSize;
            }
            ProductController controller = new ProductController();
            int num = -1;
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            if (Versioned.IsNumeric(Strings.Replace(literal.ID, "gallerythumburl", "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(literal.ID, "gallerythumburl", "", 1, -1, CompareMethod.Binary)) - 1;
            }
            literal.ID = "";
            if (num >= 0)
            {
                ArrayList productImageList = controller.GetProductImageList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (productImageList.Count >= (num + 1))
                {
                    NB_Store_ProductImageInfo info = (NB_Store_ProductImageInfo) productImageList[num];
                    string imageURL = info.ImageURL;
                    int imageID = info.ImageID;
                    if (SharedFunctions.GetStoreSettingBoolean(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "PortalID")), "diskthumbnails.flag"))
                    {
                        imageURL = new ThumbFunctions().GetThumbURLName(imageURL, str2, thumbH);
                        if (imageURL == "")
                        {
                            imageURL = this._StoreInstallPath + "makethumbnail.ashx?Image=" + imageID.ToString() + "&amp;w=" + str2 + "&amp;tabid=" + Conversions.ToString(this._TabID) + "&amp;h=" + thumbH;
                        }
                    }
                    else
                    {
                        imageURL = this._StoreInstallPath + "makethumbnail.ashx?Image=" + imageID.ToString() + "&amp;w=" + str2 + "&amp;tabid=" + Conversions.ToString(this._TabID) + "&amp;h=" + thumbH;
                    }
                    literal.Text = imageURL;
                }
                else
                {
                    literal.Text = "";
                }
            }
            else
            {
                literal.Text = "";
            }
            if (literal.Text == "")
            {
                literal.Visible = false;
            }
            if (literal.Visible)
            {
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void GalleryUrl_DataBinding(object sender, EventArgs e)
        {
            ProductController controller = new ProductController();
            int num = -1;
            string thumbSize = "";
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            string[] strArray = literal.ID.Split(new char[] { ':' });
            if (strArray.GetUpperBound(0) == 1)
            {
                thumbSize = strArray[1];
            }
            if (Versioned.IsNumeric(Strings.Replace(strArray[0], "galleryurl", "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(strArray[0], "galleryurl", "", 1, -1, CompareMethod.Binary)) - 1;
            }
            literal.ID = "";
            if (num >= 0)
            {
                ArrayList productImageList = controller.GetProductImageList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (productImageList.Count >= (num + 1))
                {
                    NB_Store_ProductImageInfo info = (NB_Store_ProductImageInfo) productImageList[num];
                    string imageURL = info.ImageURL;
                    if (thumbSize != "")
                    {
                        ThumbFunctions functions = new ThumbFunctions();
                        imageURL = functions.GetThumbURLName(imageURL, functions.getThumbWidth(thumbSize), functions.getThumbHeight(thumbSize));
                    }
                    literal.Text = imageURL;
                }
                else
                {
                    literal.Text = "";
                }
            }
            else
            {
                literal.Text = "";
            }
            if (literal.Text == "")
            {
                literal.Visible = false;
            }
            if (literal.Visible)
            {
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void GatewayButton_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            GatewayWrapper wrapper = new GatewayWrapper();
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            literal.Text = wrapper.GetButtonHtml(currentPortalSettings.PortalId, Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "OrderID")), SharedFunctions.GetCurrentCulture(), literal.Text);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void GatewayRadio_DataBinding(object sender, EventArgs e)
        {
            RadioButtonList rbl = (RadioButtonList) sender;
            this.CreateGatewayRadioButList(rbl, false);
        }

        private decimal getAmountWithAppliedTax(int PortalID, int ProductID, decimal Amount)
        {
            ProductController controller = new ProductController();
            TaxCalcController controller2 = new TaxCalcController(PortalID);
            decimal num2 = Amount;
            NB_Store_ModelInfo modelByProductID = controller.GetModelByProductID(ProductID, SharedFunctions.GetCurrentCulture());
            NB_Store_TaxRatesInfo info2 = controller2.getTaxRateUsed(PortalID, modelByProductID.ModelID);
            if (info2 != null)
            {
                switch (controller2.getTaxOption())
                {
                    case "2":
                        return new decimal((Convert.ToDouble(Amount) / (100.0 + Conversions.ToDouble(info2.TaxPercent))) * 100.0);

                    case "3":
                        num2 = new decimal(Convert.ToDouble(Amount) * (1.0 + (Conversions.ToDouble(info2.TaxPercent) / 100.0)));
                        break;
                }
            }
            return num2;
        }

        private string getBestPrice(DataListItem container, bool FormatAsCurrency, ref string PriceType)
        {
            string str3;
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "Lang"));
            int num = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "ProductID"));
            if (SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, lang))
            {
                str3 = this.getFromDealerPrice(container, FormatAsCurrency);
                PriceType = "DEALER";
                return str3;
            }
            if (this.getSalePrice(container, false) == "")
            {
                str3 = this.getFromPrice(container, FormatAsCurrency);
                PriceType = "FROM";
                return str3;
            }
            str3 = this.getSalePrice(container, FormatAsCurrency);
            PriceType = "SALE";
            return str3;
        }

        private string getBestPriceOutput(DataListItem container, bool FormatAsCurrency)
        {
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "Lang"));
            string strInput = "";
            string priceType = "";
            strInput = SharedFunctions.GetStoreSettingText(currentPortalSettings.PortalId, "bestprice.template", lang);
            if (strInput == "")
            {
                string str4 = this.getBestPrice(container, FormatAsCurrency, ref priceType);
                switch (priceType)
                {
                    case "FROM":
                        return this.getFromPriceOutput(container, FormatAsCurrency);

                    case "SALE":
                        return this.getSalePriceOutput(container, FormatAsCurrency);

                    case "DEALER":
                        str4 = this.getFromDealerPriceOutput(container, FormatAsCurrency);
                        break;
                }
                return str4;
            }
            return this.ReplacePriceTokens(container, strInput);
        }

        private string getFromDealerPrice(DataListItem container, bool FormatAsCurrency)
        {
            ProductController controller = new ProductController();
            double num3 = -1.0;
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            string cacheKey = "";
            string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "Lang"));
            
            
            int productID = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "ProductID"));
            cacheKey = SharedFunctions.GetCacheKey("getFromDealerPrice_" + FormatAsCurrency.ToString(), currentPortalSettings.PortalId, Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "ProductID")));
            if (((DataCache.GetCache(cacheKey) == null) & (cacheKey != "")) | SharedFunctions.GetStoreSettingBoolean(currentPortalSettings.PortalId, "debug.mode", "None"))
            {
                IEnumerator enumerator=null;
                ArrayList list = controller.GetModelList(currentPortalSettings.PortalId, productID, lang, SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture()));
                try
                {
                    enumerator = list.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        NB_Store_ModelInfo current = (NB_Store_ModelInfo) enumerator.Current;
                        if ((Convert.ToDouble(current.DealerCost) < num3) & (decimal.Compare(current.DealerCost, decimal.Zero) > 0))
                        {
                            num3 = Convert.ToDouble(current.DealerCost);
                        }
                        else if (num3 == -1.0)
                        {
                            num3 = Convert.ToDouble(current.DealerCost);
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                if (FormatAsCurrency)
                {
                    return SharedFunctions.FormatToStoreCurrency(num3);
                }
                return Strings.Format(num3, "0.00");
            }
            return Conversions.ToString(DataCache.GetCache(cacheKey));
        }

        private string getFromDealerPriceOutput(DataListItem container, bool FormatAsCurrency)
        {
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "Lang"));

            if (SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, lang))
            {
                NB_Store_SettingsTextInfo info = new SettingsController().GetSettingsText(currentPortalSettings.PortalId, "dealerprice.template", lang);
                if (info == null)
                {
                    return this.getFromDealerPrice(container, FormatAsCurrency).Replace("$", string.Empty);
                }
                return this.ReplacePriceTokens(container, info.SettingText);
            }
            return "";
        }

        private string getFromPrice(DataListItem container, bool FormatAsCurrency)
        {
            double num = Conversions.ToDouble(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "FromPrice"));
            if (!((num > 0.0) | (this._ZeroPriceMsg == "")))
            {
                return this._ZeroPriceMsg;
            }
            if (FormatAsCurrency)
            {
                return SharedFunctions.FormatToStoreCurrency(num);
            }
            //remove .00
            return Strings.Format(num, "0");
            //return Strings.Format(num, "0.00");
        }

        private string getFromPriceOutput(DataListItem container, bool FormatAsCurrency)
        {
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            SettingsController controller = new SettingsController();
            string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "Lang"));
            NB_Store_SettingsTextInfo info = controller.GetSettingsText(currentPortalSettings.PortalId, "fromprice.template", lang);
            if (info == null)
            {
                return this.getFromPrice(container, FormatAsCurrency);
            }
            return this.ReplacePriceTokens(container, info.SettingText);
        }

        private string getFromPriceWithAppliedTax(DataListItem container, bool FormatAsCurrency)
        {
            double num = Conversions.ToDouble(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "FromPrice"));
            if (num <= 0.0)
            {
                return "";
            }
            double a = Conversions.ToDouble(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "ProductID"));
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            num = Convert.ToDouble(this.getAmountWithAppliedTax(currentPortalSettings.PortalId, (int) Math.Round(a), new decimal(num)));
            if (FormatAsCurrency)
            {
                return SharedFunctions.FormatToStoreCurrency(num);
            }
            return Strings.Format(num, "0.00");
        }

        private string getSalePrice(DataListItem container, bool FormatAsCurrency)
        {
            return this.getSalePrice(container, FormatAsCurrency, false);
        }

        private string getSalePrice(DataListItem container, bool FormatAsCurrency, bool ApplyTax)
        {
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            string cacheKey = "";
            cacheKey = SharedFunctions.GetCacheKey("getSalePrice_" + FormatAsCurrency.ToString() + this._UserInfo.UserID.ToString(), currentPortalSettings.PortalId, Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "ProductID")));
            if ((((DataCache.GetCache(cacheKey) == null) & (cacheKey != "")) | SharedFunctions.GetStoreSettingBoolean(currentPortalSettings.PortalId, "debug.mode", "None")) | (this._UserInfo.UserID >= 0))
            {
                string str2;
                IEnumerator enumerator=null;
                double num3 = 0.0;
                CartController controller = new CartController();
                ProductController controller2 = new ProductController();
                PromoController controller3 = new PromoController();
                int productID = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "ProductID"));
                string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "Lang"));
                ArrayList list = controller2.GetModelList(currentPortalSettings.PortalId, productID, lang, SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture()));
                double num = 9999999.0;
                try
                {
                    enumerator = list.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        NB_Store_ModelInfo current = (NB_Store_ModelInfo) enumerator.Current;
                        if (Convert.ToDouble(current.UnitCost) < num)
                        {
                            num = Convert.ToDouble(current.UnitCost);
                            num3 = Convert.ToDouble(controller3.GetSalePrice(current, this._UserInfo));
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                if ((num3 <= 0.0) | (num <= 0.0))
                {
                    str2 = "";
                }
                else
                {
                    if (ApplyTax)
                    {
                        num3 = Convert.ToDouble(this.getAmountWithAppliedTax(currentPortalSettings.PortalId, productID, new decimal(num3)));
                    }
                    if (FormatAsCurrency)
                    {
                        str2 = SharedFunctions.FormatToStoreCurrency(num3);
                    }
                    else
                    {
                        str2 = Strings.Format(num3, "0.00");
                    }
                }
                if (this._UserInfo.UserID == -1)
                {
                    DataCache.SetCache(cacheKey, str2, DateAndTime.DateAdd(DateInterval.Day, 1.0, DateAndTime.Now));
                }
                return str2;
            }
            return Conversions.ToString(DataCache.GetCache(cacheKey));
        }

        private string getSalePriceOutput(DataListItem container, bool FormatAsCurrency)
        {
            string cacheKey = "";
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            cacheKey = SharedFunctions.GetCacheKey("getSalePriceOutput_" + FormatAsCurrency.ToString(), currentPortalSettings.PortalId, Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "ProductID")));
            if ((((DataCache.GetCache(cacheKey) == null) & (cacheKey != "")) | SharedFunctions.GetStoreSettingBoolean(currentPortalSettings.PortalId, "debug.mode", "None")) | (this._UserInfo.UserID >= 0))
            {
                SettingsController controller = new SettingsController();
                string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "Lang"));
                string objObject = this.getSalePrice(container, FormatAsCurrency);
                if (objObject != "")
                {
                    NB_Store_SettingsTextInfo info = controller.GetSettingsText(currentPortalSettings.PortalId, "saleprice.template", lang);
                    if (info != null)
                    {
                        objObject = this.ReplacePriceTokens(container, info.SettingText);
                    }
                }
                if (this._UserInfo.UserID == -1)
                {
                    DataCache.SetCache(cacheKey, objObject, DateAndTime.DateAdd(DateInterval.Day, 1.0, DateAndTime.Now));
                }
                return objObject;
            }
            return Conversions.ToString(DataCache.GetCache(cacheKey));
        }

        private string getTaxPercentApplied(DataListItem container)
        {
            double a = Conversions.ToDouble(DataBinder.Eval(RuntimeHelpers.GetObjectValue(container.DataItem), "ProductID"));
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            ProductController controller = new ProductController();
            TaxCalcController controller2 = new TaxCalcController(currentPortalSettings.PortalId);
            NB_Store_ModelInfo modelByProductID = controller.GetModelByProductID((int) Math.Round(a), SharedFunctions.GetCurrentCulture());
            if (modelByProductID != null)
            {
                NB_Store_TaxRatesInfo info2 = controller2.getTaxRateUsed(currentPortalSettings.PortalId, modelByProductID.ModelID);
                if (info2 != null)
                {
                    return info2.TaxPercent.ToString();
                }
            }
            return "";
        }

        private string getTemplateXML(DataListItem Container)
        {
            IEnumerator enumerator=null;
            string left = "";
            left = "<root>";
            string right = "EditLink";
            left = left + "<" + right + "><![CDATA[" + DotNetNuke.Common.Globals.NavigateURL(this._TabID, this._EditCtrlKey, new string[] { "mid=" + this._ModuleID, Conversions.ToString(Operators.ConcatenateObject("ProdID=", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), "ProductID"))), "RtnTab=" + this._TabID.ToString(), "PageIndex=" + this._PageIndex.ToString(), "CatID=" + this._CatID.ToString() }) + "]]></" + right + ">";
            right = "TabID";
            left = left + "<" + right + "><![CDATA[" + this._TabID.ToString() + "]]></" + right + ">";
            right = "PageIndex";
            left = left + "<" + right + "><![CDATA[" + this._PageIndex.ToString() + "]]></" + right + ">";
            right = "ModulePath";
            left = left + "<" + right + "><![CDATA[" + this._StoreInstallPath + "]]></" + right + ">";
            right = "ModuleID";
            left = left + "<" + right + "><![CDATA[" + this._ModuleID.ToString() + "]]></" + right + ">";
            right = "ThumbSize";
            left = left + "<" + right + "><![CDATA[" + this._ThumbSize.ToString() + "]]></" + right + ">";
            right = "ModuleEdit";
            left = left + "<" + right + "><![CDATA[" + this._blnHasModuleEditPermissions.ToString() + "]]></" + right + ">";
            right = "GallerySize";
            left = left + "<" + right + "><![CDATA[" + this._GalleryThumbSize.ToString() + "]]></" + right + ">";
            right = "EditCtrlKey";
            left = left + "<" + right + "><![CDATA[" + this._EditCtrlKey + "]]></" + right + ">";
            right = "CatID";
            left = left + "<" + right + "><![CDATA[" + this._CatID.ToString() + "]]></" + right + ">";
            right = "ProductID";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "PortalID";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "Featured";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "Archived";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "IsDeleted";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "CreatedByUser";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "CreatedDate";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "ModifiedDate";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "ProductRef";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "Lang";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "Description";
            left = left + "<" + right + "><![CDATA[" + HttpUtility.HtmlDecode(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right))) + "]]></" + right + ">";
            right = "Summary";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "ImageURL";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "ImageDESC";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "ImageID";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "FromPrice";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "ProductName";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "QtyRemaining";
            left = Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">")));
            right = "QtyStockSet";
            left = Conversions.ToString(Operators.ConcatenateObject(Conversions.ToString(Operators.ConcatenateObject(left, Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("<" + right + "><![CDATA[", DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), right)), "]]></"), right), ">"))), DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), "XMLdata"))) + "<related>";
            int productID = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), "ProductID"));
            int portalID = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(Container.DataItem), "PortalID"));
            ProductController controller = new ProductController();
            Export export = new Export();
            ArrayList list = controller.GetProductRelatedList(portalID, productID, SharedFunctions.GetCurrentCulture(), -1, false);
            try
            {
                enumerator = list.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_ProductRelatedInfo current = (NB_Store_ProductRelatedInfo) enumerator.Current;
                    NB_Store_ProductsInfo product = controller.GetProduct(current.RelatedProductID, SharedFunctions.GetCurrentCulture());
                    left = left + "<item>";
                    left = left + controller.getProductLinkXML(product, this._ProductTabID, this._CatID);
                    double num3 = Convert.ToDouble(controller.GetFromPrice(product.PortalID, product.ProductID));
                    left = left + "<fromprice>";
                    left = left + num3.ToString();
                    left = left + "</fromprice>";
                    left = left + "<frompricecurrency>";
                    left = left + SharedFunctions.FormatToStoreCurrency(num3);
                    left = left + "</frompricecurrency>";
                    left = left + XmlUtils.Serialize(current);
                    left = left + export.GetProductXML(current.RelatedProductID, SharedFunctions.GetCurrentCulture());
                    left = left + "</item>";
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return (left + "</related>" + "</root>");
        }

        private void Image_DataBinding(object sender, EventArgs e)
        {
            string str2;
            string thumbH = "0";
            if (!Versioned.IsNumeric(this._ThumbSize))
            {
                string[] strArray = this._ThumbSize.Split(new char[] { 'x' });
                str2 = strArray[0];
                if (strArray.GetUpperBound(0) == 1)
                {
                    thumbH = strArray[1];
                }
            }
            else
            {
                str2 = this._ThumbSize;
            }
            Image image = (Image) sender;
            DataListItem namingContainer = (DataListItem) image.NamingContainer;
            int num = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageID"));
            if (SharedFunctions.GetStoreSettingBoolean(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "PortalID")), "diskthumbnails.flag"))
            {
                ThumbFunctions functions = new ThumbFunctions();
                string imgPathName = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageURL"));
                image.ImageUrl = functions.GetThumbURLName(imgPathName, str2, thumbH);
                if (image.ImageUrl == "")
                {
                    image.ImageUrl = this._StoreInstallPath + "makethumbnail.ashx?Image=" + num.ToString() + "&w=" + str2 + "&tabid=" + Conversions.ToString(this._TabID) + "&h=" + thumbH;
                }
            }
            else
            {
                image.ImageUrl = this._StoreInstallPath + "makethumbnail.ashx?Image=" + num.ToString() + "&w=" + str2 + "&tabid=" + Conversions.ToString(this._TabID) + "&h=" + thumbH;
            }
            if (Operators.ConditionalCompareObjectEqual(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageDesc"), "", false))
            {
                image.AlternateText = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "SEOName"));
                if (image.AlternateText == "")
                {
                    image.AlternateText = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductName"));
                }
            }
            else
            {
                image.AlternateText = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageDesc"));
            }
            image.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void ImageLB_DataBinding(object sender, EventArgs e)
        {
            string str5;
            string thumbH = "0";
            if (!Versioned.IsNumeric(this._ThumbSize))
            {
                string[] strArray = this._ThumbSize.Split(new char[] { 'x' });
                str5 = strArray[0];
                if (strArray.GetUpperBound(0) == 1)
                {
                    thumbH = strArray[1];
                }
            }
            else
            {
                str5 = this._ThumbSize;
            }
            string expression = "<A HREF=\"[Product:ImageURL]\" rel=\"GRP1\" class=\"nyroModal\" title=\"[Product:ImageDesc]\"><img border=\"0\" src=\"[Product:ImageThumb]\" alt=\"[Product:ImageDesc]\"/></A>";
            SettingsController controller = new SettingsController();
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            int num = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageID"));
            string replacement = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageURL"));
            NB_Store_SettingsInfo info = controller.GetSetting(currentPortalSettings.PortalId, "lightboxtemplate.name", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
            string settingName = "nyromodal.template";
            if (info != null)
            {
                settingName = info.SettingValue;
            }
            NB_Store_SettingsTextInfo info2 = controller.GetSettingsText(currentPortalSettings.PortalId, settingName, Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
            if (info2 != null)
            {
                expression = HttpUtility.HtmlDecode(info2.SettingText);
            }
            if (replacement == "")
            {
                replacement = "noimage.png";
                expression = "<img border=\"0\" src=\"[Product:ImageThumb]\" alt=\"[Product:ImageDesc]\"/>";
                info2 = controller.GetSettingsText(currentPortalSettings.PortalId, "noimage.template", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (info2 != null)
                {
                    expression = HttpUtility.HtmlDecode(info2.SettingText);
                }
            }
            expression = Strings.Replace(expression, "[Product:ImageURL]", replacement, 1, -1, CompareMethod.Binary);
            if (Operators.ConditionalCompareObjectEqual(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageDesc"), "", false))
            {
                if (Operators.ConditionalCompareObjectEqual(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "SEOName"), "", false))
                {
                    expression = Strings.Replace(expression, "[Product:ImageDesc]", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductName")), 1, -1, CompareMethod.Binary);
                }
                else
                {
                    expression = Strings.Replace(expression, "[Product:ImageDesc]", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "SEOName")), 1, -1, CompareMethod.Binary);
                }
            }
            else
            {
                expression = Strings.Replace(expression, "[Product:ImageDesc]", Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageDesc")), 1, -1, CompareMethod.Binary);
            }
            if (SharedFunctions.GetStoreSettingBoolean(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "PortalID")), "diskthumbnails.flag"))
            {
                ThumbFunctions functions = new ThumbFunctions();
                string imgPathName = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageURL"));
                string str7 = functions.GetThumbURLName(imgPathName, str5, thumbH);
                if (str7 == "")
                {
                    expression = Strings.Replace(expression, "[Product:ImageThumb]", this._StoreInstallPath + "makethumbnail.ashx?Image=" + num.ToString() + "&amp;w=" + str5 + "&amp;tabid=" + Conversions.ToString(this._TabID) + "&amp;h=" + thumbH, 1, -1, CompareMethod.Binary);
                }
                else
                {
                    expression = Strings.Replace(expression, "[Product:ImageThumb]", str7, 1, -1, CompareMethod.Binary);
                }
            }
            else
            {
                expression = Strings.Replace(expression, "[Product:ImageThumb]", this._StoreInstallPath + "makethumbnail.ashx?Image=" + num.ToString() + "&amp;w=" + str5 + "&amp;tabid=" + Conversions.ToString(this._TabID) + "&amp;h=" + thumbH, 1, -1, CompareMethod.Binary);
            }
            literal.Text = expression;
            if (literal.Visible)
            {
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void ImageURL_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            string str = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageURL"));
            literal.Text = str;
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        public void InstantiateIn(Control container)
        {
            int upperBound = this._aryTempl.GetUpperBound(0);
            for (int i = 0; i <= upperBound; i++)
            {
                if (this._aryTempl[i] != null)
                {
                    LinkButton button;
                    HiddenField field;
                    Literal literal;
                    switch (this._aryTempl[i].ToUpper())
                    {
                        case "TAG:PRODUCTID":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.ProductID_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:PRODUCTNAME":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.ProductName_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:PRODUCTREF":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.ProductRef_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:MANUFACTURER":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.Manufacturer_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:SUMMARY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.Summary_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:SUMMARYHTML":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.SummaryHTML_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:DESCRIPTION":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.Description_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:LINK":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.Link_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:LINKSIMPLE":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.LinkSimple_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:FROMPRICE":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.FromPrice_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:FROMPRICETAX":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.FromPriceTax_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:FROMPRICETAXCURRENCY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.FromPriceTaxCurrency_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:TAXPERCENT":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.TaxPercentApplied_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:FROMPRICECURRENCY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.FromPriceCurrency_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:DEALERPRICE":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.DealerPrice_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:DEALERPRICECURRENCY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.DealerPriceCurrency_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:CURRENCYSYMBOL":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.CurrencySymbol_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:CURRENCYISOCODE":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.CurrencyISOcode_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:QTYREMAINING":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.QtyRemaining_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:STOCKPERCENT":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.StockPercent_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:STOCKPERCENTSOLD":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.StockPercentSold_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:STOCKPERCENTINPROCESS":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.StockPercentInProcess_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:STOCKPERCENTACTUAL":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.StockPercentActual_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:SALEPRICE":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.SalePrice_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:SALEPRICECURRENCY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.SalePriceCurrency_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:BESTPRICE":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.BestPrice_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:BESTPRICECURRENCY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.BestPriceCurrency_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:IMAGE":
                        {
                            Image child = new Image();
                            child.DataBinding += new EventHandler(this.Image_DataBinding);
                            container.Controls.Add(child);
                            continue;
                        }
                        case "TAG:IMAGEURL":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.ImageURL_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:CATIMAGEURL":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.CatImageURL_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:CATNAME":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.CatName_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:THUMBURL":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.ThumbURL_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:IMAGELIGHTBOX":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.ImageLB_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:THUMBSIZE":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.ThumbSize_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:STOREINSTALLPATH":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.StoreInstallPath_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:SOLDOUTIMG":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.SoldOutImg_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:EDITLINK":
                        {
                            HyperLink link = new HyperLink();
                            link.DataBinding += new EventHandler(this.EditLink_DataBinding);
                            container.Controls.Add(link);
                            continue;
                        }
                        case "TAG:ADDTOBASKET":
                        {
                            button = new LinkButton();
                            button.DataBinding += new EventHandler(this.AddToBasket_DataBinding);
                            container.Controls.Add(button);
                            field = new HiddenField {
                                ID = "hfModel"
                            };
                            container.Controls.Add(field);
                            continue;
                        }
                        case "TAG:WEBSITEURL":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.WebsiteURL_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:END":
                        {
                            literal = new Literal {
                                Text = ""
                            };
                            literal.DataBinding += new EventHandler(this.Visible_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:PRICEBEST":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.PriceBest_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:PRICESALE":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.PriceSale_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:PRICEDEALER":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.PriceDealer_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:PRICEBESTCURRENCY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.PriceBestCurrency_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:PRICESALECURRENCY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.PriceSaleCurrency_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:PRICESALETAXCURRENCY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.PriceSaleTaxCurrency_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                        case "TAG:PRICEDEALERCURRENCY":
                        {
                            literal = new Literal();
                            literal.DataBinding += new EventHandler(this.PriceDealerCurrency_DataBinding);
                            container.Controls.Add(literal);
                            continue;
                        }
                    }
                    if (this._aryTempl[i].ToUpper().StartsWith("TAG:UPLOAD"))
                    {
                        FileUpload upload = new FileUpload();
                        upload = (FileUpload) this.assignProperties(this._aryTempl[i], upload, "fu");
                        upload.DataBinding += new EventHandler(this.TestCtrlDisplay_DataBinding);
                        container.Controls.Add(upload);
                    }
                    else if (this._aryTempl[i].ToUpper().StartsWith("TAG:ADDTOBASKET"))
                    {
                        string[] strArray = this._aryTempl[i].Split(new char[] { ':' });
                        button = new LinkButton();
                        button.DataBinding += new EventHandler(this.AddToBasket_DataBinding);
                        container.Controls.Add(button);
                        field = new HiddenField {
                            ID = "hfModel",
                            Value = strArray[2]
                        };
                        container.Controls.Add(field);
                    }
                    else if (this._aryTempl[i].ToUpper().StartsWith("TAG:PURCHASE"))
                    {
                        button = new LinkButton();
                        string[] strArray2 = this._aryTempl[i].Split(new char[] { ':' });
                        button.Text = strArray2[2];
                        button.DataBinding += new EventHandler(this.Purchase_DataBinding);
                        container.Controls.Add(button);
                    }
                    else
                    {
                        RadioButtonList list2;
                        if (this._aryTempl[i].ToUpper().StartsWith("TAG:GATEWAYRADIO"))
                        {
                            list2 = new RadioButtonList();
                            list2 = (RadioButtonList) this.assignProperties(this._aryTempl[i], list2, "");
                            list2.ID = "rblGateway";
                            list2.DataBinding += new EventHandler(this.GatewayRadio_DataBinding);
                            container.Controls.Add(list2);
                        }
                        else if (this._aryTempl[i].ToUpper().StartsWith("TAG:GATEWAY"))
                        {
                            string[] strArray3 = this._aryTempl[i].Split(new char[] { ':' });
                            literal = new Literal {
                                Text = strArray3[2]
                            };
                            literal.DataBinding += new EventHandler(this.GatewayButton_DataBinding);
                            container.Controls.Add(literal);
                        }
                        else if (this._aryTempl[i].ToUpper().StartsWith("TAG:DATABIND"))
                        {
                            string[] strArray4 = this._aryTempl[i].Split(new char[] { ':' });
                            literal = new Literal {
                                Text = strArray4[2]
                            };
                            literal.DataBinding += new EventHandler(this.ClassDataBind_DataBinding);
                            container.Controls.Add(literal);
                        }
                        else if (this._aryTempl[i].ToUpper().StartsWith("TAG:SETTING"))
                        {
                            string[] strArray5 = this._aryTempl[i].Split(new char[] { ':' });
                            literal = new Literal {
                                Text = strArray5[2]
                            };
                            literal.DataBinding += new EventHandler(this.Setting_DataBinding);
                            container.Controls.Add(literal);
                        }
                        else if (this._aryTempl[i].ToUpper().StartsWith("TAG:TEST"))
                        {
                            string[] strArray6 = this._aryTempl[i].Split(new char[] { ':' });
                            literal = new Literal {
                                Text = strArray6[2]
                            };
                            literal.DataBinding += new EventHandler(this.TokenTest_DataBinding);
                            container.Controls.Add(literal);
                        }
                        else if (this._aryTempl[i].ToUpper().StartsWith("TAG:ADDRELATED"))
                        {
                            button = new LinkButton();
                            button.DataBinding += new EventHandler(this.AddToRelated_DataBinding);
                            button = (LinkButton) this.assignProperties(this._aryTempl[i], button, "");
                            container.Controls.Add(button);
                        }
                        else if (this._aryTempl[i].ToUpper().StartsWith("TAG:ADDTOWISHLIST"))
                        {
                            button = new LinkButton();
                            button.DataBinding += new EventHandler(this.AddToWishList_DataBinding);
                            button = (LinkButton) this.assignProperties(this._aryTempl[i], button, "");
                            container.Controls.Add(button);
                        }
                        else if (this._aryTempl[i].ToUpper().StartsWith("TAG:REMOVEFROMWISHLIST"))
                        {
                            button = new LinkButton();
                            button.DataBinding += new EventHandler(this.RemoveFromWishList_DataBinding);
                            button = (LinkButton) this.assignProperties(this._aryTempl[i], button, "");
                            container.Controls.Add(button);
                        }
                        else
                        {
                            DropDownList list;
                            TextBox box2;
                            if (this._aryTempl[i].ToUpper().StartsWith("TAG:QTY"))
                            {
                                if (this._QtyLimit <= 20)
                                {
                                    list = new DropDownList();
                                    list = (DropDownList) this.assignProperties(this._aryTempl[i], list, "ddl");
                                    int num4 = this._QtyLimit;
                                    for (int j = 1; j <= num4; j++)
                                    {
                                        list.Items.Add(j.ToString());
                                    }
                                    list.DataBinding += new EventHandler(this.QtyDDL_DataBinding);
                                    container.Controls.Add(list);
                                }
                                else
                                {
                                    box2 = new TextBox {
                                        MaxLength = 6,
                                        Text = "1",
                                        Width = Unit.Parse("32px")
                                    };
                                    box2 = (TextBox) this.assignProperties(this._aryTempl[i], box2, "txt");
                                    box2.DataBinding += new EventHandler(this.QtyInput_DataBinding);
                                    container.Controls.Add(box2);
                                    RangeValidator validator2 = new RangeValidator {
                                        ErrorMessage = "*",
                                        Text = "",
                                        MaximumValue = Conversions.ToString(this._QtyLimit),
                                        MinimumValue = Conversions.ToString(1)
                                    };
                                    validator2 = (RangeValidator) this.assignProperties(this._aryTempl[i], validator2, "val");
                                    validator2.ControlToValidate = "txtqty";
                                    validator2.DataBinding += new EventHandler(this.QtyVal_DataBinding);
                                    container.Controls.Add(validator2);
                                    RequiredFieldValidator validator = new RequiredFieldValidator {
                                        ErrorMessage = "*",
                                        Text = ""
                                    };
                                    validator = (RequiredFieldValidator) this.assignProperties(this._aryTempl[i], validator, "rval");
                                    validator.ControlToValidate = "txtqty";
                                    validator.DataBinding += new EventHandler(this.QtyRVal_DataBinding);
                                    container.Controls.Add(validator);
                                }
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAG:OPTION"))
                            {
                                if (this._aryTempl[i].ToUpper().StartsWith("TAG:OPTIONNAME"))
                                {
                                    literal = new Literal {
                                        ID = Strings.Replace(this._aryTempl[i].ToLower(), "tag:", "", 1, -1, CompareMethod.Binary)
                                    };
                                    literal.DataBinding += new EventHandler(this.OptionName_DataBinding);
                                    container.Controls.Add(literal);
                                }
                                else
                                {
                                    CheckBox box;
                                    if (this._aryTempl[i].ToUpper().StartsWith("TAG:OPTIONRADIO"))
                                    {
                                        list2 = new RadioButtonList();
                                        list2 = (RadioButtonList) this.assignProperties(this._aryTempl[i], list2, "");
                                        list2.DataBinding += new EventHandler(this.OptionRadio_DataBinding);
                                        container.Controls.Add(list2);
                                        box = new CheckBox();
                                        box = (CheckBox) this.assignProperties(this._aryTempl[i], box, "chk");
                                        box.Visible = false;
                                        container.Controls.Add(box);
                                    }
                                    else if (this._aryTempl[i].ToUpper().StartsWith("TAG:OPTIONTEXT"))
                                    {
                                        box2 = new TextBox();
                                        box2 = (TextBox) this.assignProperties(this._aryTempl[i], box2, "");
                                        box2.DataBinding += new EventHandler(this.OptionText_DataBinding);
                                        container.Controls.Add(box2);
                                    }
                                    else if (this._aryTempl[i].ToUpper().StartsWith("TAG:OPTIONVALRANGE"))
                                    {
                                        RangeValidator validator3 = new RangeValidator();
                                        validator3 = (RangeValidator) this.assignProperties(this._aryTempl[i], validator3, "");
                                        validator3.DataBinding += new EventHandler(this.TestCtrlDisplay_DataBinding);
                                        container.Controls.Add(validator3);
                                    }
                                    else if (this._aryTempl[i].ToUpper().StartsWith("TAG:OPTIONVALREGX"))
                                    {
                                        RegularExpressionValidator validator4 = new RegularExpressionValidator();
                                        validator4 = (RegularExpressionValidator) this.assignProperties(this._aryTempl[i], validator4, "");
                                        validator4.DataBinding += new EventHandler(this.TestCtrlDisplay_DataBinding);
                                        container.Controls.Add(validator4);
                                    }
                                    else if (this._aryTempl[i].ToUpper().StartsWith("TAG:OPTIONVALREQ"))
                                    {
                                        RequiredFieldValidator validator5 = new RequiredFieldValidator();
                                        validator5 = (RequiredFieldValidator) this.assignProperties(this._aryTempl[i], validator5, "");
                                        validator5.DataBinding += new EventHandler(this.TestCtrlDisplay_DataBinding);
                                        container.Controls.Add(validator5);
                                    }
                                    else if (this._aryTempl[i].ToUpper().StartsWith("TAG:OPTIONVALSUMMARY"))
                                    {
                                        ValidationSummary summary = new ValidationSummary();
                                        summary = (ValidationSummary) this.assignProperties(this._aryTempl[i], summary, "");
                                        summary.DataBinding += new EventHandler(this.TestCtrlDisplay_DataBinding);
                                        container.Controls.Add(summary);
                                    }
                                    else
                                    {
                                        list = new DropDownList();
                                        list = (DropDownList) this.assignProperties(this._aryTempl[i], list, "");
                                        list.DataBinding += new EventHandler(this.Option_DataBinding);
                                        container.Controls.Add(list);
                                        box = new CheckBox();
                                        box = (CheckBox) this.assignProperties(this._aryTempl[i], box, "chk");
                                        box.Visible = false;
                                        container.Controls.Add(box);
                                    }
                                }
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAG:MODELS"))
                            {
                                if (this._aryTempl[i].ToUpper().StartsWith("TAG:MODELSRADIO2"))
                                {
                                    list2 = new RadioButtonList();
                                    list2 = (RadioButtonList) this.assignProperties(this._aryTempl[i], list2, "");
                                    list2.ID = "rblModelsel";
                                    list2.DataBinding += new EventHandler(this.ModelRadio2_DataBinding);
                                    container.Controls.Add(list2);
                                }
                                else if (this._aryTempl[i].ToUpper().StartsWith("TAG:MODELSRADIO"))
                                {
                                    list2 = new RadioButtonList();
                                    list2 = (RadioButtonList) this.assignProperties(this._aryTempl[i], list2, "");
                                    list2.ID = "rblModel";
                                    list2.DataBinding += new EventHandler(this.ModelRadio_DataBinding);
                                    container.Controls.Add(list2);
                                }
                                else if (this._aryTempl[i].ToUpper().StartsWith("TAG:MODELSTABLE"))
                                {
                                    literal = new Literal();
                                    literal.DataBinding += new EventHandler(this.ModelTable_DataBinding);
                                    container.Controls.Add(literal);
                                }
                                else if (this._aryTempl[i].ToUpper().StartsWith("TAG:MODELS2"))
                                {
                                    list = new DropDownList();
                                    list = (DropDownList) this.assignProperties(this._aryTempl[i], list, "");
                                    list.ID = "ddlModelsel";
                                    list.DataBinding += new EventHandler(this.Model2_DataBinding);
                                    container.Controls.Add(list);
                                }
                                else
                                {
                                    list = new DropDownList();
                                    list = (DropDownList) this.assignProperties(this._aryTempl[i], list, "");
                                    list.ID = "ddlModel";
                                    list.DataBinding += new EventHandler(this.Model_DataBinding);
                                    container.Controls.Add(list);
                                }
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAG:XMLDATA"))
                            {
                                string[] strArray7 = this._aryTempl[i].Split(new char[] { ':' });
                                literal = new Literal {
                                    Text = Strings.Replace(strArray7[2].ToLower(), "(", "[", 1, -1, CompareMethod.Binary)
                                    
                                };
                                literal.Text = Strings.Replace(literal.Text, ")", "]", 1, -1, CompareMethod.Binary);
                                literal.DataBinding += new EventHandler(this.XMLData_DataBinding);
                                container.Controls.Add(literal);
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAG:GALLERYTHUMBURL"))
                            {
                                literal = new Literal {
                                    ID = Strings.Replace(this._aryTempl[i].ToLower(), "tag:", "", 1, -1, CompareMethod.Binary)
                                };
                                literal.DataBinding += new EventHandler(this.GalleryThumbUrl_DataBinding);
                                container.Controls.Add(literal);
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAG:GALLERYURL"))
                            {
                                literal = new Literal {
                                    ID = Strings.Replace(this._aryTempl[i].ToLower(), "tag:", "", 1, -1, CompareMethod.Binary)
                                };
                                literal.DataBinding += new EventHandler(this.GalleryUrl_DataBinding);
                                container.Controls.Add(literal);
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAG:GALLERYID"))
                            {
                                literal = new Literal {
                                    ID = Strings.Replace(this._aryTempl[i].ToLower(), "tag:", "", 1, -1, CompareMethod.Binary)
                                };
                                literal.DataBinding += new EventHandler(this.GalleryId_DataBinding);
                                container.Controls.Add(literal);
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAGXML"))
                            {
                                literal = new Literal {
                                    Text = Strings.Replace(this._aryTempl[i].ToLower(), "tagxml:", "", 1, -1, CompareMethod.Binary)
                                };
                                literal.DataBinding += new EventHandler(this.XML_DataBinding);
                                container.Controls.Add(literal);
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAGEXTRA"))
                            {
                                literal = new Literal {
                                    Text = Strings.Replace(this._aryTempl[i].ToLower(), "tagextra:", "", 1, -1, CompareMethod.Binary)
                                };
                                literal.DataBinding += new EventHandler(this.EXTRA_DataBinding);
                                container.Controls.Add(literal);
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAG:GALLERY"))
                            {
                                literal = new Literal {
                                    ID = Strings.Replace(this._aryTempl[i].ToLower(), "tag:", "", 1, -1, CompareMethod.Binary)
                                };
                                literal.DataBinding += new EventHandler(this.Gallery_DataBinding);
                                container.Controls.Add(literal);
                            }
                            else if (this._aryTempl[i].ToUpper().StartsWith("TAG:DOC"))
                            {
                                if (this._aryTempl[i].ToUpper().StartsWith("TAG:DOCLINK") | this._aryTempl[i].StartsWith("TAG:DOCPURCHASEDLINK"))
                                {
                                    button = new LinkButton();
                                    button = (LinkButton) this.assignProperties(this._aryTempl[i], button, "");
                                    button.CausesValidation = false;
                                    button.DataBinding += new EventHandler(this.DocLink_DataBinding);
                                    container.Controls.Add(button);
                                }
                                else if (this._aryTempl[i].ToUpper().StartsWith("TAG:DOCDESC"))
                                {
                                    literal = new Literal();
                                    literal = (Literal) this.assignProperties(this._aryTempl[i], literal, "");
                                    literal.DataBinding += new EventHandler(this.DocDesc_DataBinding);
                                    container.Controls.Add(literal);
                                }
                                else if (this._aryTempl[i].ToUpper().StartsWith("TAG:DOCNAME"))
                                {
                                    literal = new Literal();
                                    literal = (Literal) this.assignProperties(this._aryTempl[i], literal, "");
                                    literal.DataBinding += new EventHandler(this.DocName_DataBinding);
                                    container.Controls.Add(literal);
                                }
                                else
                                {
                                    ImageButton button2 = new ImageButton();
                                    button2 = (ImageButton) this.assignProperties(this._aryTempl[i], button2, "");
                                    button2.CausesValidation = false;
                                    button2.DataBinding += new EventHandler(this.Doc_DataBinding);
                                    container.Controls.Add(button2);
                                }
                            }
                            else
                            {
                                literal = new Literal {
                                    Text = this._aryTempl[i]
                                };
                                literal.DataBinding += new EventHandler(this.VisibleMode_DataBinding);
                                container.Controls.Add(literal);
                            }
                        }
                    }
                }
            }
        }

        private void Link_DataBinding(object sender, EventArgs e)
        {
            IEnumerator enumerator=null;
            Literal literal = (Literal) sender;
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            string expression = SharedFunctions.GetStoreSetting(currentPortalSettings.PortalId, "urlname.column", "None");
            try
            {
                if (expression != "")
                {
                    expression = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), expression));
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                expression = "";
                ProjectData.ClearProjectError();
            }
            ProductController controller2 = new ProductController();
            CategoryController controller = new CategoryController();
            NB_Store_CategoriesInfo category = new NB_Store_CategoriesInfo();
            ArrayList categoriesAssigned = controller2.GetCategoriesAssigned(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")));
            try
            {
                enumerator = categoriesAssigned.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_ProductCategoryInfo current = (NB_Store_ProductCategoryInfo) enumerator.Current;
                    category = controller.GetCategory(current.CategoryID, SharedFunctions.GetCurrentCulture());
                    if (category.ProductTemplate != "")
                    {
                        this._CatID = category.CategoryID;
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            literal.Text = SharedFunctions.GetProductUrlByProductID(currentPortalSettings.PortalId, this._ProductTabID, Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), this._CatID, expression, false, SharedFunctions.GetCurrentCulture());
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void LinkSimple_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = DotNetNuke.Common.Globals.NavigateURL(this._ProductTabID, "", new string[] { Conversions.ToString(Operators.ConcatenateObject("ProdID=", DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"))) });
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Manufacturer_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = HttpUtility.HtmlEncode(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Manufacturer")));
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Model_DataBinding(object sender, EventArgs e)
        {
            DropDownList ddl = (DropDownList) sender;
            this.CreateModelDropDownList(ddl, false);
        }

        private void Model2_DataBinding(object sender, EventArgs e)
        {
            DropDownList ddl = (DropDownList) sender;
            this.CreateModelDropDownList(ddl, true);
        }

        private void ModelRadio_DataBinding(object sender, EventArgs e)
        {
            RadioButtonList rbl = (RadioButtonList) sender;
            this.CreateModelRadioButList(rbl, false);
        }

        private void ModelRadio2_DataBinding(object sender, EventArgs e)
        {
            RadioButtonList rbl = (RadioButtonList) sender;
            this.CreateModelRadioButList(rbl, true);
        }

        private void ModelTable_DataBinding(object sender, EventArgs e)
        {
            SettingsController controller3 = new SettingsController();
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            ProductController controller = new ProductController();
            PromoController controller2 = new PromoController();
            NB_Store_ModelInfo objModelInfo = new NB_Store_ModelInfo();
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            int productID = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
            string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang"));
            NB_Store_SettingsTextInfo info2 = controller3.GetSettingsText(currentPortalSettings.PortalId, "modeltablerow.template", lang);
            if (info2 != null)
            {
                string settingText = info2.SettingText;
                if (settingText.Length > 0)
                {
                    info2 = controller3.GetSettingsText(currentPortalSettings.PortalId, "modeltable.template", lang);
                    if (info2 != null)
                    {
                        string expression = info2.SettingText;
                        if (expression.Length > 0)
                        {
                            string replacement = "";
                            ArrayList list = SharedFunctions.GetAvailableModelList(currentPortalSettings.PortalId, productID, lang, SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture()));
                            if (list.Count > 0)
                            {
                                IEnumerator enumerator=null;
                                HtmlTableRow row = new HtmlTableRow();
                                try
                                {
                                    enumerator = list.GetEnumerator();
                                    while (enumerator.MoveNext())
                                    {
                                        objModelInfo = (NB_Store_ModelInfo) enumerator.Current;
                                        TokenStoreReplace replace = new TokenStoreReplace(objModelInfo);
                                        replacement = replacement + replace.DoTokenReplace(settingText);
                                    }
                                }
                                finally
                                {
                                    if (enumerator is IDisposable)
                                    {
                                        (enumerator as IDisposable).Dispose();
                                    }
                                }
                                expression = Strings.Replace(expression, "[TAG:TABLEROWS]", replacement, 1, -1, CompareMethod.Binary);
                                literal.Text = HttpUtility.HtmlDecode(expression);
                            }
                        }
                        else
                        {
                            literal.Text = "*** 'modeltable.template' is blank ***";
                        }
                    }
                    else
                    {
                        literal.Text = "*** No 'modeltable.template' exists ***";
                    }
                }
                else
                {
                    literal.Text = "*** 'modeltablerow.template' is blank ***";
                }
            }
            else
            {
                literal.Text = "*** No 'modeltablerow.template' exists ***";
            }
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Option_DataBinding(object sender, EventArgs e)
        {
            DropDownList list2 = null;
            ProductController controller = new ProductController();
            int num = -1;
            string optionValueDesc = "";
            list2 = (DropDownList) sender;
            list2.Visible = false;
            DataListItem namingContainer = (DataListItem) list2.NamingContainer;
            if (Versioned.IsNumeric(Strings.Replace(list2.ID, "option", "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(list2.ID, "option", "", 1, -1, CompareMethod.Binary)) - 1;
            }
            if (num >= 0)
            {
                ArrayList optionList = controller.GetOptionList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (optionList.Count >= (num + 1))
                {
                    string id = "chk" + list2.ID;
                    CheckBox box = (CheckBox) namingContainer.FindControl(id);
                    if (box != null)
                    {
                        box.Visible = false;
                    }
                    NB_Store_OptionInfo info = (NB_Store_OptionInfo) optionList[num];
                    optionList = controller.GetOptionValueListWithInterface(info.OptionID, info.Lang);
                    if (optionList.Count == 1)
                    {
                        list2.Visible = false;
                        NB_Store_OptionValueInfo info3 = (NB_Store_OptionValueInfo) optionList[0];
                        if (box != null)
                        {
                            optionValueDesc = info3.OptionValueDesc;
                            if (decimal.Compare(info3.AddedCost, decimal.Zero) > 0)
                            {
                                optionValueDesc = optionValueDesc + " +" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(info3.AddedCost));
                            }
                            if (decimal.Compare(info3.AddedCost, decimal.Zero) < 0)
                            {
                                optionValueDesc = optionValueDesc + " -" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(info3.AddedCost));
                            }
                            box.Text = info3.OptionValueDesc;
                            box.Attributes.Add("OptionValueID", Conversions.ToString(info3.OptionValueID));
                            box.Visible = true;
                            box.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
                        }
                    }
                    else if (optionList.Count > 1)
                    {
                        IEnumerator enumerator=null;
                        try
                        {
                            enumerator = optionList.GetEnumerator();
                            while (enumerator.MoveNext())
                            {
                                NB_Store_OptionValueInfo current = (NB_Store_OptionValueInfo) enumerator.Current;
                                ListItem item = new ListItem();
                                optionValueDesc = current.OptionValueDesc;
                                if (decimal.Compare(current.AddedCost, decimal.Zero) > 0)
                                {
                                    optionValueDesc = optionValueDesc + " +" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(current.AddedCost));
                                }
                                if (decimal.Compare(current.AddedCost, decimal.Zero) < 0)
                                {
                                    optionValueDesc = optionValueDesc + " -" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(current.AddedCost));
                                }
                                item.Text = optionValueDesc;
                                item.Value = Conversions.ToString(current.OptionValueID);
                                list2.Items.Add(item);
                            }
                        }
                        finally
                        {
                            if (enumerator is IDisposable)
                            {
                                (enumerator as IDisposable).Dispose();
                            }
                        }
                        list2.SelectedIndex = 0;
                        list2.Visible = true;
                        list2.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
                    }
                }
            }
        }

        private void OptionName_DataBinding(object sender, EventArgs e)
        {
            ProductController controller = new ProductController();
            int num = -1;
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            if (Versioned.IsNumeric(Strings.Replace(literal.ID, "optionname", "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(literal.ID, "optionname", "", 1, -1, CompareMethod.Binary)) - 1;
            }
            if (num >= 0)
            {
                ArrayList optionList = controller.GetOptionList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (optionList.Count >= (num + 1))
                {
                    literal.Text = ((NB_Store_OptionInfo) optionList[num]).OptionDesc;
                }
                else
                {
                    literal.Text = "";
                }
            }
            else
            {
                literal.Text = "";
            }
            if (literal.Text == "")
            {
                literal.Visible = false;
            }
            if (literal.Visible)
            {
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void OptionRadio_DataBinding(object sender, EventArgs e)
        {
            RadioButtonList list2 = null;
            ProductController controller = new ProductController();
            int num = -1;
            string optionValueDesc = "";
            list2 = (RadioButtonList) sender;
            list2.Visible = false;
            DataListItem namingContainer = (DataListItem) list2.NamingContainer;
            if (Versioned.IsNumeric(Strings.Replace(list2.ID, "optionradio", "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(list2.ID, "optionradio", "", 1, -1, CompareMethod.Binary)) - 1;
            }
            if (num >= 0)
            {
                ArrayList optionList = controller.GetOptionList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (optionList.Count >= (num + 1))
                {
                    string id = "chk" + list2.ID;
                    CheckBox box = (CheckBox) namingContainer.FindControl(id);
                    if (box != null)
                    {
                        box.Visible = false;
                    }
                    NB_Store_OptionInfo info = (NB_Store_OptionInfo) optionList[num];
                    optionList = controller.GetOptionValueListWithInterface(info.OptionID, info.Lang);
                    if (optionList.Count == 1)
                    {
                        list2.Visible = false;
                        NB_Store_OptionValueInfo info3 = (NB_Store_OptionValueInfo) optionList[0];
                        if (box != null)
                        {
                            optionValueDesc = info3.OptionValueDesc;
                            if (decimal.Compare(info3.AddedCost, decimal.Zero) > 0)
                            {
                                optionValueDesc = optionValueDesc + " +" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(info3.AddedCost));
                            }
                            if (decimal.Compare(info3.AddedCost, decimal.Zero) < 0)
                            {
                                optionValueDesc = optionValueDesc + " -" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(info3.AddedCost));
                            }
                            box.Text = info3.OptionValueDesc;
                            box.Attributes.Add("OptionValueID", Conversions.ToString(info3.OptionValueID));
                            box.Visible = true;
                        }
                    }
                    else if (optionList.Count > 1)
                    {
                        IEnumerator enumerator=null;
                        try
                        {
                            enumerator = optionList.GetEnumerator();
                            while (enumerator.MoveNext())
                            {
                                NB_Store_OptionValueInfo current = (NB_Store_OptionValueInfo) enumerator.Current;
                                ListItem item = new ListItem();
                                optionValueDesc = current.OptionValueDesc;
                                if (decimal.Compare(current.AddedCost, decimal.Zero) > 0)
                                {
                                    optionValueDesc = optionValueDesc + " +" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(current.AddedCost));
                                }
                                if (decimal.Compare(current.AddedCost, decimal.Zero) < 0)
                                {
                                    optionValueDesc = optionValueDesc + " -" + SharedFunctions.FormatToStoreCurrency(Convert.ToDouble(current.AddedCost));
                                }
                                item.Text = optionValueDesc;
                                item.Value = Conversions.ToString(current.OptionValueID);
                                list2.Items.Add(item);
                            }
                        }
                        finally
                        {
                            if (enumerator is IDisposable)
                            {
                                (enumerator as IDisposable).Dispose();
                            }
                        }
                        list2.SelectedIndex = 0;
                        list2.Visible = true;
                    }
                }
            }
            if (list2.Visible)
            {
                list2.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void OptionText_DataBinding(object sender, EventArgs e)
        {
            TextBox box = null;
            ProductController controller = new ProductController();
            int num = -1;
            box = (TextBox) sender;
            box.Visible = false;
            DataListItem namingContainer = (DataListItem) box.NamingContainer;
            if (Versioned.IsNumeric(Strings.Replace(box.ID, "optiontext", "", 1, -1, CompareMethod.Binary)))
            {
                num = Conversions.ToInteger(Strings.Replace(box.ID, "optiontext", "", 1, -1, CompareMethod.Binary)) - 1;
            }
            if (num >= 0)
            {
                ArrayList optionList = controller.GetOptionList(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID")), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                if (optionList.Count >= (num + 1))
                {
                    box.Visible = true;
                    NB_Store_OptionInfo objInfo = (NB_Store_OptionInfo) optionList[num];
                    box.Attributes.Add("OptionDesc", objInfo.OptionDesc);
                    optionList = controller.GetOptionValueListWithInterface(objInfo.OptionID, objInfo.Lang);
                    if (optionList.Count >= 1)
                    {
                        NB_Store_OptionValueInfo info2 = (NB_Store_OptionValueInfo) optionList[0];
                        box.Text = info2.OptionValueDesc;
                    }
                    if (OptionInterface.Instance() != null)
                    {
                        PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
                        box.Text = OptionInterface.Instance().GetTextboxDefault(currentPortalSettings.PortalId, objInfo);
                    }
                }
            }
            if (box.Visible)
            {
                box.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private string[] ParseTemplateText(string TemplText)
        {
            char[] separator = new char[] { '[', ']' };
            bool flag = false;
            flag = false;
            if ((Strings.InStr(TemplText, "[[", CompareMethod.Binary) > 0) | (Strings.InStr(TemplText, "]]", CompareMethod.Binary) > 0))
            {
                TemplText = Strings.Replace(TemplText, "[[", "**SQROPEN**", 1, -1, CompareMethod.Binary);
                TemplText = Strings.Replace(TemplText, "]]", "**SQRCLOSE**", 1, -1, CompareMethod.Binary);
                flag = true;
            }
            string[] strArray2 = TemplText.Split(separator);
            if (flag)
            {
                int upperBound = strArray2.GetUpperBound(0);
                for (int i = 0; i <= upperBound; i++)
                {
                    if (strArray2[i].Contains("**SQROPEN**"))
                    {
                        strArray2[i] = Strings.Replace(strArray2[i], "**SQROPEN**", "[", 1, -1, CompareMethod.Binary);
                    }
                    if (strArray2[i].Contains("**SQRCLOSE**"))
                    {
                        strArray2[i] = Strings.Replace(strArray2[i], "**SQRCLOSE**", "]", 1, -1, CompareMethod.Binary);
                    }
                }
            }
            return strArray2;
        }

        private void PriceBest_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            string priceType = null;
            literal.Text = this.getBestPrice(namingContainer, false, ref priceType);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void PriceBestCurrency_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            string priceType = null;
            literal.Text = this.getBestPrice(namingContainer, true, ref priceType);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void PriceDealer_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getFromDealerPrice(namingContainer, false);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void PriceDealerCurrency_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getFromDealerPrice(namingContainer, true);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void PriceSale_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getSalePrice(namingContainer, false);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void PriceSaleCurrency_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getSalePrice(namingContainer, true);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void PriceSaleTaxCurrency_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getSalePrice(namingContainer, true, true);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void ProductID_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void ProductName_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = HttpUtility.HtmlEncode(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductName")));
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void ProductRef_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = HttpUtility.HtmlEncode(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductRef")));
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Purchase_DataBinding(object sender, EventArgs e)
        {
            LinkButton button = (LinkButton) sender;
            DataListItem namingContainer = (DataListItem) button.NamingContainer;
            button.CommandName = "Purchase";
            SharedFunctions.assignByReflection(button, button.Text);
            if (button.Text == "")
            {
                button.Text = "Purchase >>";
            }
            if (button.Visible)
            {
                button.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void QtyDDL_DataBinding(object sender, EventArgs e)
        {
            DropDownList list = (DropDownList) sender;
            list.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void QtyInput_DataBinding(object sender, EventArgs e)
        {
            TextBox box = (TextBox) sender;
            DataListItem namingContainer = (DataListItem) box.NamingContainer;
            if (Operators.ConditionalCompareObjectEqual(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "QtyRemaining"), 0, false))
            {
                box.Visible = false;
            }
            if (box.Visible)
            {
                box.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void QtyRemaining_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "QtyRemaining"));
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void QtyRVal_DataBinding(object sender, EventArgs e)
        {
            RequiredFieldValidator validator = (RequiredFieldValidator) sender;
            validator.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void QtyVal_DataBinding(object sender, EventArgs e)
        {
            RangeValidator validator = (RangeValidator) sender;
            validator.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void RemoveFromWishList_DataBinding(object sender, EventArgs e)
        {
            LinkButton button = (LinkButton) sender;
            DataListItem namingContainer = (DataListItem) button.NamingContainer;
            button.CommandArgument = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
            button.CommandName = "RemoveFromWishList";
            button.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private string ReplacePriceTokens(DataListItem container, string strInput)
        {
            string expression = strInput;
            string priceType = "";
            return Strings.Replace(HttpUtility.HtmlDecode(Strings.Replace(Strings.Replace(HttpUtility.HtmlDecode(Strings.Replace(Strings.Replace(HttpUtility.HtmlDecode(Strings.Replace(Strings.Replace(HttpUtility.HtmlDecode(Strings.Replace(expression, "[TAG:DEALERPRICECURRENCY]", this.getFromDealerPrice(container, true), 1, -1, CompareMethod.Binary)), "[TAG:DEALERPRICE]", this.getFromDealerPrice(container, false), 1, -1, CompareMethod.Binary), "[TAG:FROMPRICECURRENCY]", this.getFromPrice(container, true), 1, -1, CompareMethod.Binary)), "[TAG:FROMPRICE]", this.getFromPrice(container, false), 1, -1, CompareMethod.Binary), "[TAG:SALEPRICECURRENCY]", this.getSalePrice(container, true), 1, -1, CompareMethod.Binary)), "[TAG:SALEPRICE]", this.getSalePrice(container, false), 1, -1, CompareMethod.Binary), "[TAG:BESTPRICECURRENCY]", this.getBestPrice(container, true, ref priceType), 1, -1, CompareMethod.Binary)), "[TAG:BESTPRICE]", this.getBestPrice(container, false, ref priceType), 1, -1, CompareMethod.Binary);
        }

        private void SalePrice_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getSalePriceOutput(namingContainer, false);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void SalePriceCurrency_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getSalePriceOutput(namingContainer, true);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Setting_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            literal.Text = SharedFunctions.GetStoreSetting(currentPortalSettings.PortalId, literal.Text, SharedFunctions.GetCurrentCulture());
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void SoldOutImg_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = "";
            if (this._LockStockOnCart)
            {
                PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
                int productID = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
                string lang = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang"));
                ProductStockLevels levels = SharedFunctions.getProductStockLevels(namingContainer);
                if (levels != null)
                {
                    if (levels.PercentSold == 100)
                    {
                        literal.Text = HttpUtility.HtmlDecode(this._SoldOutImg);
                    }
                }
                else if (SharedFunctions.GetAvailableModelList(currentPortalSettings.PortalId, productID, lang, SharedFunctions.IsDealer(currentPortalSettings.PortalId, this._UserInfo, SharedFunctions.GetCurrentCulture())).Count == 0)
                {
                    literal.Text = HttpUtility.HtmlDecode(this._SoldOutImg);
                }
            }
            else if (Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "QtyRemaining")) == 0)
            {
                literal.Text = HttpUtility.HtmlDecode(this._SoldOutImg);
            }
            if (literal.Text == "")
            {
                literal.Visible = false;
            }
            if (literal.Visible)
            {
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void StockPercent_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            ProductStockLevels levels = SharedFunctions.getProductStockLevels(namingContainer);
            if (levels != null)
            {
                literal.Text = Conversions.ToString(levels.Percent);
            }
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void StockPercentActual_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            ProductStockLevels levels = SharedFunctions.getProductStockLevels(namingContainer);
            if (levels != null)
            {
                literal.Text = Conversions.ToString(levels.PercentActual);
            }
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void StockPercentInProcess_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            ProductStockLevels levels = SharedFunctions.getProductStockLevels(namingContainer);
            if (levels != null)
            {
                literal.Text = Conversions.ToString(levels.PercentInProgess);
            }
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void StockPercentSold_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            ProductStockLevels levels = SharedFunctions.getProductStockLevels(namingContainer);
            if (levels != null)
            {
                literal.Text = Conversions.ToString(levels.PercentSold);
            }
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void StoreInstallPath_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this._StoreInstallPath;
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Summary_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = HttpUtility.HtmlEncode(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Summary")));
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void SummaryHTML_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = Strings.Replace(HttpUtility.HtmlEncode(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Summary"))), "\n", "<br/>", 1, -1, CompareMethod.Binary);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void TaxPercentApplied_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this.getTaxPercentApplied(namingContainer);
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void TestCtrlDisplay_DataBinding(object sender, EventArgs e)
        {
            Control control = (Control) sender;
            if (control.Visible)
            {
                control.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
        }

        private void TokenTest_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            TokenTest test = new TokenTest();
            SharedFunctions.assignByReflection(test, literal.Text);
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            bool flag = test.getVisibleMode(currentPortalSettings.PortalId, Conversions.ToInteger(this._ModuleID), namingContainer, this._UserInfo, Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]));
            literal.Visible = false;
            this._NestedLevel.Add(flag);
        }

        private void ThumbSize_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            literal.Text = this._ThumbSize;
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void ThumbURL_DataBinding(object sender, EventArgs e)
        {
            string str = string.Empty;
            string str3;
            string thumbH = "0";
            if (!Versioned.IsNumeric(this._ThumbSize))
            {
                string[] strArray = this._ThumbSize.Split(new char[] { 'x' });
                str3 = strArray[0];
                if (strArray.GetUpperBound(0) == 1)
                {
                    thumbH = strArray[1];
                }
            }
            else
            {
                str3 = this._ThumbSize;
            }
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            int num = Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageID"));
            if (SharedFunctions.GetStoreSettingBoolean(Conversions.ToInteger(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "PortalID")), "diskthumbnails.flag"))
            {
                ThumbFunctions functions = new ThumbFunctions();
                string imgPathName = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ImageURL"));
                str = functions.GetThumbURLName(imgPathName, str3, thumbH);
                if (str == "")
                {
                    str = this._StoreInstallPath + "makethumbnail.ashx?Image=" + num.ToString() + "&amp;w=" + str3 + "&amp;tabid=" + Conversions.ToString(this._TabID) + "&amp;h=" + thumbH;
                }
            }
            else
            {
                str = this._StoreInstallPath + "makethumbnail.ashx?Image=" + num.ToString() + "&amp;w=" + str3 + "&amp;tabid=" + Conversions.ToString(this._TabID) + "&amp;h=" + thumbH;
            }
            if (num <= 0)
            {
                str = this._StoreInstallPath + "makethumbnail.ashx?Image=" + DotNetNuke.Common.Globals.QueryStringEncode(this._StoreInstallPath + "img/noimage.png") + "&amp;w=" + str3 + "&amp;tabid=" + Conversions.ToString(this._TabID) + "&amp;h=" + thumbH;
            }
            literal.Text = str;
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void Visible_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            literal.Visible = false;
            if (this._NestedLevel.Count > 0)
            {
                this._NestedLevel.RemoveAt(this._NestedLevel.Count - 1);
            }
        }

        private void VisibleMode_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void WebsiteURL_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            literal.Text = currentPortalSettings.PortalAlias.HTTPAlias;
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }

        private void XML_DataBinding(object sender, EventArgs e)
        {
            bool flag = false;
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            flag = SharedFunctions.GetStoreSettingBoolean(currentPortalSettings.PortalId, "debug.mode", "None");
            string cacheKey = "";
            try
            {
                string[] strArray = literal.Text.Split(new char[] { ':' });
                string right = "";
                string settingName = "";
                settingName = strArray[0];
                if (strArray.GetUpperBound(0) >= 1)
                {
                    right = strArray[1];
                }
                string path = currentPortalSettings.HomeDirectoryMapPath + strArray[0];
                string str4 = "";
                cacheKey = "dummykey";
                if (right.ToLower() != "getorderxml")
                {
                    if (DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID") != null)
                    {
                        str4 = Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "ProductID"));
                    }
                    if (DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang") != null)
                    {
                        cacheKey = SharedFunctions.GetCacheKey(Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Path.GetFileName(path) + "_", DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")), "_"), right), "_"), this._CatID)), currentPortalSettings.PortalId, Conversions.ToInteger(str4));
                    }
                }
                if ((((DataCache.GetCache(cacheKey) == null) & (cacheKey != "")) | flag) | (right.ToLower() == "getorderxml"))
                {
                    string left = "";
                    if (right == "")
                    {
                        left = this.getTemplateXML(namingContainer);
                    }
                    else if (right.ToLower() == "xmlgetproductsincat")
                    {
                        left = new ProductController().xmlGetProductsInCat(currentPortalSettings.PortalId, this._CatID, Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")), this._ProductTabID);
                    }
                    else if (right.ToLower() == "getproductxml")
                    {
                        left = new Export().GetProductXML(Conversions.ToInteger(str4), Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Lang")));
                    }
                    else if (right.ToLower() == "getorderxml")
                    {
                        Export instance = new Export();
                        left = "<root>";
                        left = Conversions.ToString(Operators.ConcatenateObject(Conversions.ToString(Operators.ConcatenateObject(Conversions.ToString(Operators.ConcatenateObject(left, NewLateBinding.LateGet(instance, null, "GetOrderXML", new object[] { RuntimeHelpers.GetObjectValue(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "OrderID")) }, null, null, null))), Operators.ConcatenateObject(Operators.ConcatenateObject("<Stg2FormXML>", DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Stg2FormXML")), "</Stg2FormXML>"))), Operators.ConcatenateObject(Operators.ConcatenateObject("<Stg3FormXML>", DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "Stg3FormXML")), "</Stg3FormXML>"))) + "</root>";
                    }
                    XmlDocument document = new XmlDocument();
                    string objObject = "";
                    string str8 = "";
                    str8 = SharedFunctions.GetCacheKey(Path.GetFileName(path), currentPortalSettings.PortalId);
                    if (str8 != "")
                    {
                        if ((DataCache.GetCache(str8) == null) | flag)
                        {
                            objObject = SharedFunctions.GetStoreSettingText(currentPortalSettings.PortalId, settingName, SharedFunctions.GetCurrentCulture(), false, true);
                            if (objObject == "")
                            {
                                document.Load(path);
                                objObject = document.OuterXml;
                            }
                            DataCache.SetCache(str8, objObject, DateAndTime.DateAdd(DateInterval.Day, 1.0, DateAndTime.Now));
                        }
                        else
                        {
                            objObject = Conversions.ToString(DataCache.GetCache(str8));
                        }
                    }
                    if (flag)
                    {
                        document = new XmlDocument();
                        document.LoadXml(left);
                        document.Save(currentPortalSettings.HomeDirectoryMapPath + "debugProduct_" + right + ".xml");
                    }
                    DataCache.SetCache(cacheKey, SharedFunctions.XSLTransInMemory(left, objObject), DateAndTime.DateAdd(DateInterval.Day, 1.0, DateAndTime.Now));
                }
                literal.Text = Conversions.ToString(DataCache.GetCache(cacheKey));
                literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                if (flag)
                {
                    literal.Text = exception.ToString();
                }
                ProjectData.ClearProjectError();
            }
        }

        private void XMLData_DataBinding(object sender, EventArgs e)
        {
            Literal literal = (Literal) sender;
            DataListItem namingContainer = (DataListItem) literal.NamingContainer;
            if (Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")) == "")
            {
                literal.Text = "";
            }
            else if (literal.Text.Contains("/edt/"))
            {
                literal.Text = HttpUtility.HtmlDecode(SharedFunctions.getGenXMLvalue(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")), literal.Text));
            }
            else
            {
                literal.Text = SharedFunctions.getGenXMLvalue(Conversions.ToString(DataBinder.Eval(RuntimeHelpers.GetObjectValue(namingContainer.DataItem), "XMLData")), literal.Text);
            }
            literal.Visible = Conversions.ToBoolean(this._NestedLevel[this._NestedLevel.Count - 1]);
        }
    }
}

